/*
 * Copyright (c) 2020, 2023, 3044483124@qq.com All rights reserved.
 *
 */
package cn.itcast;

import java.util.Calendar;

/**
 * <p>Project: JavaStudy - If2
 * <p>Powered by jiangbo On 2023-02-25
 * 11:08:17
 * <p>Created by IntelliJ IDEA
 *
 * @author jiangbo [3044483124@qq.com]
 * @version 1.0
 * @since 8/17
 */
public class If2 {
    public static void main(String[] args) {
        System.out.println(Calendar.getInstance().get(Calendar.DATE));
        for (int i = 0; i < Calendar.getInstance().get(Calendar.DATE); i++) {
            Calendar c = Calendar.getInstance();
            c.set(Calendar.DATE, 1);
            c.add(Calendar.DATE, i);
//1-7的数字 1 星期日 2 星期一3 星期二 4 星期三 5 星期四 6 星期五 7 星期六
            int k = c.get(Calendar.DAY_OF_WEEK);
            String s = String.format("%tY年%<tm月%<td日", c);
//System.out.println(s);
//此处if效率低，不推荐使用
//if (k == 1) System.out.printf("%s是星期日%n", s);
//if (k == 2) System.out.printf("%s是星期一%n", s);
//if (k == 3) System.out.printf("%s是星期二%n", s);
//if (k == 4) System.out.printf("%s是星期三%n", s);
//if (k == 5) System.out.printf("%s是星期四%n", s);
//if (k == 6) System.out.printf("%s是星期五%n", s);
            //if (k == 7) System.out.printf("%s是星期六%n", s);
            if (k == 1) {
                System.out.printf("%s是星期日%n", s);
            } else if (k == 2) {
                System.out.printf("%s是星期一%n", s);
            } else if (k == 3) {
                System.out.printf("%s是星期二%n", s);
            } else if (k == 4) {
                System.out.printf("%s是星期三%n", s);
            } else if (k == 5) {
                System.out.printf("%s是星期四%n", s);
            } else if (k == 6) {
                System.out.printf("%s是星期五%n", s);
            } else {
                System.out.printf("%s是星期六%n", s);
            }
        }


    }
    }



